package org.zfes.snowier.cloud.zbss.asf.router;

import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.zfes.snowier.web.controller.BaseController;
import org.zfes.snowier.cloud.zbss.asf.biz.dto.FaceUserResDto;
import org.zfes.snowier.cloud.zbss.asf.biz.dto.ImageInfo;
import org.zfes.snowier.cloud.zbss.asf.biz.dto.UserFaceInfoCreateDto;
import org.zfes.snowier.cloud.zbss.asf.biz.dto.UserFaceInfoUpdateDto;
import org.zfes.snowier.cloud.zbss.asf.biz.model.UserFaceInfo;
import org.zfes.snowier.cloud.zbss.asf.biz.service.IFaceEngineService;
import org.zfes.snowier.cloud.zbss.asf.biz.service.IUserFaceInfoService;
import org.zfes.snowier.cloud.zbss.asf.biz.util.ImageUtil;
import org.zfes.snowier.common.file.FileResInfo;
import org.zfes.snowier.common.file.disk.UploadUitl;
import org.zfes.snowier.core.util.ZAlert;
import org.zfes.snowier.core.util.ZAssert;
import org.zfes.snowier.core.util.ZObjectUtil;
@Controller 
@RequestMapping("/user/face")
public class UserFaceInfoController extends BaseController {

	
	@Autowired
	private IUserFaceInfoService userFaceInfoService;
	
	@Autowired
	private IFaceEngineService faceEngineService;
	
	
	
	    
//==================================================================
	
    @RequestMapping(value="/createUserFaceInfo", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public  @ResponseBody Object createUserFaceInfo(UserFaceInfoCreateDto userFaceInfo){
    	UserFaceInfo user=	userFaceInfoService.createUserFaceInfo(userFaceInfo);
    	return ajaxDoneSuccess("数据操作成功 ").put("user", user.setFaceFeature(null));
    }
    
    
    @RequestMapping(value="/updateUserFaceInfo", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object updateUserFaceInfo(UserFaceInfoUpdateDto userFaceInfo){
		userFaceInfoService.updateUserFaceInfo(userFaceInfo);
		return ajaxDoneSuccess("数据操作成功 ");
    }
    
    @RequestMapping(value="/updateUserFeaturePic", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object updateUserFeaturePic(Long id,String  facePic){
		userFaceInfoService.updateUserFeaturePic(id,facePic);
		return ajaxDoneSuccess("数据操作成功 ");
    }
    
	
    @RequestMapping(value="/loadUserFaceInfo", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object loadUserFaceInfo(Long id){
		Optional<UserFaceInfo> ops = userFaceInfoService.loadUserFaceInfoById(id);
		return ajaxQuery("userFaceInfo",ops);
    }
	

	


}